<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<script type="text/javascript">
<!--
	function resetValue(obj) {
		obj.value = obj.value.replace(/^\s+|\s+$/g, '');

		if(obj.value == 'Add new language')
			obj.value = '';
		else if(obj.value == '')
			obj.value = 'Add new language';
	}

	function trim(str, chars) {
		return ltrim(rtrim(str, chars), chars);
	}
//-->
</script>

<div align="center" class="verdana12blacknormal">
	<center>
		<s:form id="form" action="insertOrUpdate.htm" method="post"
			theme="simple">
			<table width="100%">
				<tr>
					<td height="40"  align="left" class="sectionheading bottom-border">
						Translation System
					</td>
				</tr>
				<tr>
					<td valign="top" class="verdana12blacknormal">
						Edit languages settings here. To delete a language(s) just empty
						left column (the code).
						<br>
						<br>
					</td>
				</tr>
				<tr>
					<td>
						<table width="100%" border="0" cellpadding="0" cellspacing="0"
							class="Textfiled-border">

							<tr align="left">
								<td colspan="3">
									<s:actionmessage cssClass="note-red"/>
									<s:fielderror cssClass="note-red"/>
									<s:actionerror cssClass="note-red"/>
								</td>
							</tr>

							<tr align="center">
								<th align="center" bgcolor="#E9E9E9"
									class="right-border verdana12darkgreybold">
									Language
									<br>
									Short ISO 639 code
								</th>
								<th align="center" bgcolor="#E9E9E9"
									class="right-border verdana12darkgreybold">
									Name
								</th>
								<th align="center" bgcolor="#E9E9E9"
									class="verdana12darkgreybold">
									Active / Default
								</th>
							</tr>
							<s:iterator value="languagesList" status="rowstatus">
								<s:set name="classCSS" value="%{'Textfiled-no-border-odd'}"
									var="classCSS"></s:set>
								<s:set name="bgColor" value="%{'#FFFFFF'}" var="bgColor"></s:set>

								<s:if test="#rowstatus.even">
									<s:set var="classCSS" value="%{'Textfiled-no-border-even'}"></s:set>
									<s:set var="bgColor" value="%{'#F8F8F8'}"></s:set>
								</s:if>
								<s:hidden
									name="myEntitiesMap['%{languageCode}'].oldLanguageCode"
									value="%{languageCode}" />
								<tr align="center">
									<td align="center" class="verdana12Greybold right-border"
										bgcolor="<s:property value="%{bgColor}" />">
										<s:textfield
											name="myEntitiesMap['%{languageCode}'].languageCode"
											value="%{languageCode}" cssClass="%{classCSS}" theme="simple"></s:textfield>
									</td>
									<td align="center" class="verdana12Greybold right-border"
										bgcolor="<s:property value="%{bgColor}" />">
										<s:textfield
											name="myEntitiesMap['%{languageCode}'].languageName"
											value="%{languageName}" cssClass="%{classCSS}" theme="simple"></s:textfield>
									</td>
									<td align="center" class="verdana12Greybold"
										bgcolor="<s:property value="%{bgColor}" />">
										<s:select list="#{'true':'Yes','false':'No'}"
											name="myEntitiesMap['%{languageCode}'].active"
											value="%{active}" theme="simple"></s:select>
										<s:if test="%{default_ == true}">
											<input name="selectedCode" type="radio" align="middle"
												value="<s:property value="languageCode" />"
												checked="checked" />
										</s:if>
										<s:else>
											<input name="selectedCode" type="radio" align="middle"
												value="<s:property value="languageCode" />" />
										</s:else>

										<!-- <input name="langdef" value="ar" type="radio"> -->
									</td>
							</s:iterator>
							<tr align="center">
								<td align="center" class="verdana12Greybold right-border"
									bgcolor="<s:property value="#FFFFFF" />">
									<s:textfield name="languages.languageCode"
										cssClass="Textfiled-no-border-odd" theme="simple" value="" />
								</td>
								<td align="center" class="verdana12Greybold right-border"
									bgcolor="<s:property value="#FFFFFF" />">
									<s:textfield name="languages.languageName" id="newLang"
										cssClass="Textfiled-no-border-odd" theme="simple" onfocus="resetValue(this);"
										value="Add new language" maxlength="45" size="25" onblur="resetValue(this);" />
								</td>
								<td>
									<s:select list="#{'true':'Yes','false':'No'}"
										name="languages.active" theme="simple"></s:select>
									<input name="selectedCode" type="radio"
										value="<s:property value="languageCode" />" />
								</td>
							</tr>
							<tr>
					<td align="left" class="verdana12blacknormal" colspan="2" nowrap="nowrap" bgcolor="#F8F8F8">
						Translation server IP/domain:
					</td>
					<td bgcolor="#F8F8F8">
						<input size="20" value="localhost" type="text" class="Textfiled-no-border-even">
					</td>
				</tr>

				<tr>
					<td align="left" class="verdana12blacknormal" colspan="2"  nowrap="nowrap" bgcolor="#FFFFFF">
						Translation server port:
					</td>
					<td bgcolor="#FFFFFF">
						<input size="20" value="2019" type="text" class="Textfiled-no-border-odd">
					</td>
				</tr>
						</table>
					</td>
				</tr>

				<tr>
				<tr>
					<td colspan="3" align="center" width="100%">
						<s:submit type="image"
							src="../Admin-Images/save-chagnes-button.gif" />
						<img style="cursor: pointer;"
							onclick="document.getElementById('form').reset();"
							src="../Admin-Images/reset-button.gif" alt="Reset">
					</td>
				</tr>
			</table>
		</s:form>
	</center>